<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      >
    <ui:composition template="Template.xhtml">
        <ui:define name="top">
            #{bundle.create}#{bundle.order}

        </ui:define>
        <ui:define name="content">
            <!--<shiro:hasPermission name="user:C">--> 

            <f:event listener="#{customerdemandCreateMB.precreateCustomerdemand()}"
                     type="preRenderView"></f:event>
            <h:form id="form"  >

                <p:panel>


                    <p:panelGrid styleClass="noborder left" columns="2"   >


                        <h:outputText value="#{bundle.customer}#{bundle.name}" />
                        <p:selectOneMenu id="idcustomer" value="#{customerdemandCreateMB.currentCustomerid}"   required="true" editable="true" requiredMessage="#{bundle.pleaseInput}#{bundle.loginName}">
                            <f:selectItems  var="customer" value="#{customerdemandCreateMB.customerlist}" itemLabel="#{customer.idcustomer}:#{customer.iduser.name}" itemValue="#{customer.idcustomer}" />
                            <p:ajax update="address,tel,map" listener="#{customerdemandCreateMB.oncustomerchange()}" />
                        </p:selectOneMenu>
                        
                        <h:outputText value="#{bundle.save}#{bundle.customer}" />
                        <p:selectBooleanCheckbox value="#{customerdemandCreateMB.newcustomer}">
                        </p:selectBooleanCheckbox>

                        <h:outputText value="#{bundle.tel}" />
                        <p:inputText id="tel" value="#{customerdemandCreateMB.currentcustomerdemand.tel}"   required="true" requiredMessage="#{bundle.pleaseInput}#{bundle.userid}"/>

                        <h:outputText value="#{bundle.date}" />
                        <p:calendar id="servicedate"  value="#{customerdemandCreateMB.currentcustomerdemand.servicedate}"  required="true" requiredMessage="#{bundle.pleaseInput}#{bundle.date}" />

                        <h:outputText value="#{bundle.readyTime}" />
                        <p:calendar id="readyTime"  value="#{customerdemandCreateMB.currentcustomerdemand.readyTime}"  required="true" requiredMessage="#{bundle.pleaseInput}#{bundle.readyTime}" pattern="HH:mm" timeOnly="true"  />
                        <h:outputText value="#{bundle.dueDate}" />
                        <p:calendar id="dueDate"  value="#{customerdemandCreateMB.currentcustomerdemand.dueDate}"  required="true" requiredMessage="#{bundle.pleaseInput}#{bundle.dueDate}" pattern="HH:mm" timeOnly="true"  />
                        <h:outputText value="#{bundle.demand}" />
                        <p:inputText id="demand"  value="#{customerdemandCreateMB.currentcustomerdemand.requirement}"  required="true" requiredMessage="#{bundle.pleaseInput}#{bundle.demand}"   />
                        <h:outputText value="#{bundle.serviceTime}" />
                        <p:inputText id="serviceTime"  value="#{customerdemandCreateMB.currentcustomerdemand.serviceTime}"  required="true" requiredMessage="#{bundle.pleaseInput}#{bundle.serviceTime}"  />

                        <h:outputText  value="#{bundle.address}" />
                        <p:inputText id="address" class="address"  value="#{customerdemandCreateMB.currentcustomerdemand.address}"  style="width: 400px" required="true" requiredMessage="#{bundle.pleaseInput}#{bundle.address}"/>




                    </p:panelGrid> 
                    <p:fragment id="map">
                        <script type="text/javascript">
                         var caddress="#{customerdemandCreateMB.currentcustomerdemand.address}";   
                            
                        </script>
                        <h:outputScript library="js" name="map/inputAutocomplete1.js"/>
                        <p:inputText id="latitude" styleClass="nodisplay" value="#{customerdemandCreateMB.currentcustomerdemand.latitude}"   required="true" requiredMessage="#{bundle.pleaseInput}#{bundle.userid}"/>
                        <p:inputText id="longitude" styleClass="nodisplay" value="#{customerdemandCreateMB.currentcustomerdemand.longitude}"   required="true" requiredMessage="#{bundle.pleaseInput}#{bundle.userid}"/>
                         

                        <div id="bmap" style="height:300px;width:100%"></div>
                    </p:fragment>
                    <p:panelGrid styleClass="noborder left"  style="width:50% " columns="2"   >
                        <p:commandButton value="#{bundle.conform}" validateClient="true" oncomplete="#{customerdemandCreateMB.precreateCustomerdemand()}" action="#{customerdemandCreateMB.create()}"  update="@form,:growl">
                            <p:confirm header="#{bundle.conform}" message="#{bundle.conform}" icon="ui-icon-alert" />
                        </p:commandButton>
<!--                        <p:button value="#{bundle.back}#{bundle.list}"    outcome="list" style="margin-left: 15px"  >
                        </p:button>-->
                    </p:panelGrid>
                    <p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
                        <p:commandButton value="#{bundle.yes}" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
                        <p:commandButton value="#{bundle.no}" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
                    </p:confirmDialog>
                </p:panel>
            </h:form>





            <div id="searchResultPanel" style="border:1px solid #C0C0C0;width:150px;height:auto; display:none;" address=""></div>
            <!--</shiro:hasPermission>-->
        </ui:define>
    </ui:composition>
</html>

